#ifndef __OSA_DEBUG_H__
#define __OSA_DEBUG_H__

#include <devices/atos_uart.h>
#ifndef OSA_DEBUG_BUF_SIZE
#define OSA_DEBUG_BUF_SIZE 512
#endif


#define TRACE_FATAL     (1)
#define TRACE_ERROR     (2)
#define TRACE_WARN      (3)
#define TRACE_INFO      (4)
#define TRACE_DEBUG     (5)


#ifndef NDEBUG
#define TRACE osa_trace_direct
#else
#define TRACE(...)
#endif

#define THROW_ERROR(err, msg)	do {\
	TRACE("ERROR (%d) on ["__FILE__" %s %d] -> ", err, __FUNCTION__, __LINE__); \
} while (0)

#define THROW_WARNING(err, msg)	do {\
	TRACE("WARNING (%d) on ["__FILE__" %s %d] -> ", err, __FUNCTION__, __LINE__); \
} while (0)


EXTERN_C_BLOCKSTART
extern atos_uart_fd_t osa_debug_fd;
void osa_debug_init();
void osa_trace_direct(const char* format, ...);
EXTERN_C_BLOCKEND

#endif /* __OSA_DEBUG_H__ */
